package com.tvein
{
	//flash
	import flash.display.Sprite;
	import flash.events.Event;
	//pureMVC
	//custom
	import com.tvein.system.common.CommonConstants;
	import com.tvein.system.ApplicationFacade;
//
	public class System extends Sprite
	{
	 	public static const NAME:String	="System";
		
		public function System()
		{
			stage?init(null):addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(evt:Event):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
			
			var url:String = this.loaderInfo.url;
			
			if (url.indexOf("|") < 0)
			{
				//web mode
				CommonConstants.GAME_SERVER = url.substring(0, url.indexOf("/System.swf"));
			}
			else
			{
				//local mode
				CommonConstants.GAME_SERVER = "http://127.0.0.1";
			}
			
			var facade:ApplicationFacade = ApplicationFacade.getInstance(NAME);
			facade.sendNotification(ApplicationFacade.STARTUP, this);
		}
	}
}